package com.kotlin.heimaplayer.ui.activity

import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.Fragment
import com.kotlin.heimaplayer.R
import com.kotlin.heimaplayer.base.BaseActivity
import com.kotlin.heimaplayer.util.FragmentUtil
import com.kotlin.heimaplayer.util.ToolBarManager
import kotlinx.android.synthetic.main.activity_main.*
import org.jetbrains.anko.find

class MainActivity : BaseActivity(),ToolBarManager {

    override val toolbar: Toolbar by lazy { find<Toolbar>(R.id.toolbar) }

    override fun getLayoutId(): Int {
        return R.layout.activity_main
    }

    override fun initData() {
        initMainToolBar()
    }

    override fun initListener() {
        // tab切换监听
        bottomBar.setOnTabSelectListener {
            println("${it}")
            val transaction = supportFragmentManager.beginTransaction()
            transaction.replace(R.id.container,FragmentUtil.fragmentUtil.getFragment(it) as Fragment,it.toString())
            transaction.commit()
        }
    }
}
